<%-- 
    Document   : pertanyaan_baki_akaun
    Created on : Aug 9, 2012, 2:12:47 PM
    Author     : ubuntu
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Penyata Akaun</title>
        <script type="text/javascript">
            $(document).ready(function(){
//                $('form').submit( function () {
//                    return formValidation();
//                }); 
                
                $('#noAkaunDari').change(function(){                    
                    var url = '${pageContext.request.contextPath}/deposit?getNoKP' ;
                    $.get(url, 
                    {
                        noAkaun:$(this).val()
                    }, 
                    function(data){
                        $('#noKpDari').val(data);
                    }, "text");
                });
                
                 function getLastMonths(n) {
    
                    var months = new Array();
                    var today = new Date();
                    var year = today.getFullYear();
                    //var year = 2014 
                    var month = today.getMonth() + 1;
                    //var month = 5; 
                    var month2 = month;
                    var i = 0;
                    
                    if (month <= 2) {
                        do {
                            //months.push(year + (month > 9 ? "" : "0") + month);
                            //months.push(month + (year + (month > 9 ? "" : "0")));
                            months.push((month > 9 ? "" : "0") + month + " - "+ year);
                            // 06 - 2014
                            if(month == 1) {
                                month = 12;
                                year--;
                            } else {
                                month--;
                            }
                            
                            i++;
                        } while(i < month2);
                    } else {
                        do {
                            //months.push(year + (month > 9 ? "" : "0") + month);
                            //months.push(month + (year + (month > 9 ? "" : "0")));
                            months.push((month > 9 ? "" : "0") + month + " - "+ year);
                            // 06 - 2014
                            if(month == 1) {
                                month = 12;
                                year--;
                            } else {
                                month--;
                            }
                            i++;
                        } while(i < n);
                    }
                    

                    return months;

                }


                function writeMonthOptions() {   

                   var optionValues = getLastMonths(3);
                   var dropDown = document.getElementById("bulanPilihan");

                   for(var i=0; i<optionValues.length; i++) {
                       //var key = optionValues[i].slice(1,3);
                       var v = optionValues[i].slice(0,2)+optionValues[i].slice(5,9);//wil return MMyyyy format
                      // var key = optionValues[i]; ori
                       var key = v;
                       var value = optionValues[i];
                       dropDown.options[i] = new Option(value, key);
                    }
                    $("#stmt").hide();
                }

          
                writeMonthOptions();
        
            });
            
             function popup(){
                var url = '${pageContext.request.contextPath}/deposit?genReportsPenyataAkaun';
                window.open(url);
            }
            
        </script>
    </head>
    <body>
        <s:form beanclass="th.stripes.action.DepositActionBean" class="niceform">
             <s:hidden name="deposit.noAkaun" id="noAkaun"></s:hidden>
            <s:hidden name="deposit.noKp" id="noKP"></s:hidden>
            <s:hidden name="deposit.senaraiTransaksiAkaun" id="senaraiTrxn"></s:hidden>
            <div id="content">
                <s:errors/>
                <s:messages/>
                <div id="logo">
                    <span>
                        <img src="${pageContext.request.contextPath}/images/img/ribbon.png"/>               
                    </span>
                </div>
                <h3>
                    Penyata Akaun
                </h3>  
               <p>
                    <label>No. Akaun TH :</label>
                    <s:select name="deposit.noAkaunDari" class="required" id="noAkaunDari">
                        <s:option value="">Sila Pilih</s:option>
                        <c:forEach items="${actionBean.accountList}" var="item">
                            <s:option value="${item.akaunTmbhn}">${item.akaunTmbhn}</s:option>
                        </c:forEach>
                    </s:select>
                </p>   
                <p>
                    <label>No. KP Semasa :</label>
                    <s:text name="deposit.noKpDari" id="noKpDari" readonly="true"/>
                </p>
                 <p>
                    <label>Bulan :</label>
                    <s:select id="bulanPilihan" name="deposit.bulanPilihan">
                    </s:select>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  
                    <s:submit  name="checkStatement" value="Semak"  class="button green button_blockUI"/>
                <p>
                    <label></label>
                    <font size="2">Nota : <br/>Paparan penyata adalah bagi 3 bulan terkini untuk tahun semasa.</font>
                </p>

            </div>
        </s:form>
    </body>
</html>
